﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UnityEngine;
using UnityEngine.UI;

namespace Assets.Scripts.UI
{
    public class UIBelt_Panel : MonoBehaviour
    {
        #region 单例
        public static UIBelt_Panel Instance;
        void Awake()
        {
            Instance = this;
        }
        #endregion

        // 当前玩家选择的传送带上的牌
        public int currBeltSelectedCardID = -1;

        private int currCardID;

        // 当前传送带上的牌的配置，字典中的key：0是红方，1是中间，2是蓝方，3是牌堆
        public Dictionary<int, CardDefine> currBeltCardDic;

        #region 用于临时存放传送带item
        // 当前玩家选择的传送带上的牌
        private int currBeltCardID = -1;
        // 用ID去确认某个传送带的item
        public UIBelt_Item[] uIBelt_Items;
        #endregion

        #region Tip对象
        public Text getQiTip;
        public Text loseQiTip;
        #endregion


        /// <summary>
        /// 选中的传送带上的卡
        /// </summary>
        public void SelectBeltCard(int cardID)
        {
            // 如果上一次选择和本次是一样的，就无视
            if (currBeltCardID == cardID)
            {
                return;
            }
            // 找到老的ID对应的实际UIItem元素，设置他的Select为False
            if (Instance.currBeltCardDic.ContainsKey(currBeltCardID))
            {
                uIBelt_Items[currBeltCardID].IsSelect = false;
            }

            currBeltCardID = cardID;
            uIBelt_Items[currBeltCardID].IsSelect = true;

            // 让传送带面板脚本知道当前选择的卡
            Instance.currBeltSelectedCardID = currCardID;
        }

    }
}
